<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../../baselist.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
</head>
<link rel="stylesheet" href="${ctx}/zTree/css/zTreeStyle/zTreeStyle.css"/>

<script type="text/javascript" src="${ctx}/zTree/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${ctx}/zTree/js/jquery.ztree.core-3.5.min.js"></script>
<script type="text/javascript" src="${ctx}/zTree/js/jquery.ztree.excheck-3.5.min.js"></script>

<SCRIPT type="text/javascript">
		
var setting = {
		check: {
			enable: true
		},
		data: {
			simpleData: {
				enable: true
			}
		}
	};

	var zTreeObject;
	function initZtree(data) {
		//解析字符串
		var zNodes = eval("(" + data + ")");
		 zTreeObject = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
		
	}
	$(function() {
		$.ajax({
			url:"roleAction_roleModuleJsonStr?id=${id}",
			dataType:"text",
			success:function(data) {
				initZtree(data);
			}
		});
	});
	
	function submitCheckedNodes() {
		
		//获取选中的节点
		var nodes = zTreeObject.getCheckedNodes(true);
		var str = "";
		for(var i in nodes) {
			str += nodes[i].id + ",";			
		}
		
		str = str.substring(0,str.length - 1);
		$("#moduleIds").val(str);
	}
	</SCRIPT>
<body>
<form name="icform" method="post">
	<input type="hidden" name="id" value="${id}"/>
	<input type="hidden" id="moduleIds" name="moduleIds" value="" />
<div id="menubar">
<div id="middleMenubar">
<div id="innerMenubar">
  <div id="navMenubar">
<ul>
<li id="save"><a href="#" onclick="submitCheckedNodes();formSubmit('roleAction_module?cwhich=role','_self');this.blur();">保存</a></li>
<li id="back"><a href="#" onclick="formSubmit('roleAction_list','_self');this.blur();">返回</a></li>
</ul>
  </div>
</div>
</div>
</div>
<div class="textbox" id="centerTextbox">
  <div class="textbox-header">
  <div class="textbox-inner-header">
  <div class="textbox-title">
    配置 [${name}] 角色的模块  
    <div class="content_wrap">
		<div class="zTreeDemoBackground left">
			<ul id="treeDemo" class="ztree"></ul>
		</div>
	</div>
  </div> 
  </div>
  </div>
 </div>


</form>
</body>
</html>

